Automount
Updated Mar 27, 2021 ·
Tasks
Here we'll have two servers:
- tstsvr - nfs server
- tstclient - nfs-client
To-dos:
- On your server 1, set hostname to tstsvr. Set server 2 to tstclient
- Configure tstsvr to offer RW access to 2 NFS shares:
- /home/ldap/
- /data
- Ensure /home/ldap contains a subddirectory for LDAP users
- LDAP user home directories should be available on th NFS share.
- Configure automount to automatically mount user's home directories.
- Configure NFS client to automatically mount the share:
- tstsvr:/data
Solution
Server 1: NFS Server
-
Set Hostname
hostnamectl set-hostname tstsvr
-
Configure NFS Shares
Edit
/etc/exports
to define the NFS shares:/home/ldap *(rw,sync,no_root_squash)
/data *(rw,sync,no_root_squash)Ensure to run
exportfs -a
after editing to apply changes. -
Prepare /home/ldap Create a subdirectory for LDAP users:
mkdir /home/ldap/ldap_users
-
LDAP User Home Directories on NFS Ensure LDAP user home directories are mounted from NFS. This typically involves configuring LDAP to use NFS for home directories (
/home/ldap/ldap_users
). -
Configure Automount
Install autofs if not already installed:
sudo yum install autofs
Edit
/etc/auto.master
to include:/home/ldap /etc/auto.ldap
Create
/etc/auto.ldap
with content:* -rw,sync tstsvr:/home/ldap/&
Restart autofs:
sudo systemctl restart autofs
Server 2: NFS Client
-
Configure NFS Client on tstclient
Set the hostname for tstclient:
hostnamectl set-hostname tstclient
Edit
/etc/fstab
on tstclient to automatically mount/data
from tstsvr:tstsvr:/data /mnt/data nfs defaults 0 0
Mount the NFS share:
mount /mnt/data
Notes
- Ensure NFS server (
rpcbind
,nfs-server
) and client (rpcbind
,nfs-utils
) packages are installed and running on both servers. - Replace
tstsvr
andtstclient
with actual IP addresses if DNS resolution is not available. - Adjust NFS export options (
rw
,sync
,no_root_squash
, etc.) according to your security requirements.